<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="text/css">
* {
	margin: 0px;
	padding: 0px;
}

#all_div {
	width: 100%;
	margin: 0 auto;
	background-color: #f4f4f4;
}

#body_div {width：400px;
	height: 600px;
	font-size: 13px;
	border: solid 1px red;
}

form {
	border: solid 1px blue;
	margin: 0 auto;
}

table {
	margin: 0 auto;
}

a {
	text-decoration: none;
}

tr td {
	width: 140px;
	height: 40px;
	margin: 0 auto;
	text-align: center;
	border: solid 1px green;
}
</style>
</head>
<body>
	<div id="all_div">
		<div id="body_div">
			<form action="#" method="post"
				enctype="multipart/form-data" id="from"  class="form-horizontal">
				<table cellspacing="1" cellpadding="3">
					<tr>
						<td class="label">数据格式:</td>
						<td><select name="data_cat" id="data_cat">
								<option value="0">Excel</option>
						</select></td>
					</tr>
					<tr>
						<td class="label">所属分类：</td>
						<td><select id="select_cate">
								<option>选择种类</option>
						</select>
					</tr>
					<tr>
						<td class="label"><a href="" title="点击此处查看提示信息"><img
								src="../img/what.png" width="16" height="16" border="0"
								alt="点击此处查看提示信息"></a> 上传批量csv文件：</td>
						<td><input name="file" id="file" type="file" size="40">
							<br /> <span class="notice-span"
							style="display: block; font-size: 12px;" id="noticeFile">(CSV文件中一次上传商品数量最好不要超过1000，CSV文件大小最好不要超过500K.)</span></td>
					</tr>
					<tr>
						<td>&nbsp;</td>
						<td><a href="">下载批量CSV文件（繁体中文）</a></td>
					</tr>
					<tr>
						<td>&nbsp;</td>
						<td><a href="">下载批量CSV文件（美国英语）</a></td>
					</tr>
					<tr>
						<td>&nbsp;</td>
						<td><a href="">下载批量CSV文件（简体中文）</a></td>
					</tr>
					<tr align="center">
						<td colspan="2"><input name="submit" type="submit"
							id="submit" value=" 确定 " /></td>
					</tr>
				</table>
			</form>
		</div>
	</div>
	<script type="text/javascript" src="../js/jquery-3.1.0.js"></script>
	<script type="text/javascript" src="../js/jquery-form.js"></script>
	<script type="text/javascript">
		$(function() {
			$.getJSON("../CategoryServlet?method=quaryAllCaregoryName", {},
					function(data) {
						$.each(data,
								function(index, element) {
									$("#select_cate").append(
											"<option>" + element.catname
													+ "</option>");
								});

					});
			$("#select_cate").change(function() {
				var value = $(this).val();
				$("#src_goods_lists").append("<option>" + value + "</option>");
			})
			var ajax_option={
				url:"../GoodsServlet?method=fileEnter",
				success:function(data){
					alert(data);
					var result = $.parseJSON(data);
				   alert(result);
						if (result.success) {
							var index = parent.layer.getFrameIndex();
							alert("文件上传成功");
							var parentWin = parent;
							parent.layer.msg(result.message, 1, 1, function(){
								parentWin.layer.close(index);
							window.location.href="../yf/fileSuccessful.jsp";
							});
						} else {
							
							parent.layer.msg(result.message, 1, 3);
							alert("文件上传失败")
						}
					}
			};
			$("#submit").click(function(){
				alert(123);
				$("#from").ajaxSubmit(ajax_option);
			});
			
		 	$("#submit").click(function(){
				var index = parent.layer.getFrameIndex();
				parent.layer.close(index);
			});  

		})
	</script>
</body>
</html>